package com.hgyc.mom.mes.enums;

/**
 * 数据采集结果返回枚举类
 */
public enum ScanResultEnum {

    SUCCESS(1, "成功"),
    BARCODE_NOT_EXIST(2, "条码不存在"),
    BARCODE_DUPLICATE(3, "条码重复"),
    BARCODE_MISMATCH(4, "条码内容不匹配");

    private final int code;
    private final String message;

    ScanResultEnum(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    /**
     * 通过编码获取枚举
     */
    public static ScanResultEnum fromCode(int code) {
        for (ScanResultEnum result : values()) {
            if (result.code == code) {
                return result;
            }
        }
        return null;
    }

}
